package interview1719;

import leetcode.IDebug;
import leetcode.helper.H;

//
public class View4 implements IDebug {

	public int[] missingTwo(int[] nums) {
		int n = nums.length + 2;
		int ab = 0;
		for (int num : nums) {
			ab ^= num;
		}
		for (int i = 1; i <= n; i++) {
			ab ^= i;
		}
		int flag = ab & (-ab);
		int a = 0;
		for (int i = 1; i <= n; i++) {
			if ((i & flag) != 0) {
				a ^= i;
			}
		}
		for (int num : nums) {
			if ((num & flag) != 0) {
				a ^= num;
			}
		}
		return new int[] { a, ab ^ a };
	}

	@Override
	public void debug4() {
		H.compare(H.str2array3("[1,3]"), this.missingTwo(H.str2array3("[2]")));
		H.compare(H.str2array3("[2,3]"), this.missingTwo(H.str2array3("[1]")));
		H.compare(H.str2array3("[1,4]"), this.missingTwo(H.str2array3("[2,3]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		View4 v = new View4();
		v.debug4();
		int hello_word = 0;
	}
}
